import requests

from commons.entity.enum.base_url_enum import BaseUrlEnum
from commons.entity.po.user import User


class UserClient:
    def __init__(self):
        pass

    def get_all_users_by_id_list(self, user_id_list):
        url = f"{BaseUrlEnum.USER_SERVICE_URL.url}/user/getAllUsersByIdList"
        headers = {"Content-Type": "application/json"}
        response = requests.post(
            url, json={"userIdList": user_id_list}, headers=headers)

        if response.status_code == 200:
            user_data = response.json()
            users = [User(**data) for data in user_data]
            return users
        else:
            response.raise_for_status()
